<template>
  <div v-cloak>
    <input type="button" value="toggle" @click="toggleFn" />
    <transition>
      <div v-if="flag">
        <h1>{{ msg }}</h1>
      </div>
    </transition>
    <input type="button" value="toggle" @click="toggleFn2" />
    <transition name="myF">
      <div v-if="flag2">
        <h1>{{ msg }}</h1>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: "Hello World",
      flag: true,
      flag2: true,
    };
  },
  methods: {
    toggleFn() {
      this.flag = !this.flag;
    },
    toggleFn2() {
      this.flag2 = !this.flag2;
    },
  },
};
</script>

<style>
.v-enter,
.v-enter-to {
  opacity: 0;
  transform: translateX(100px);
}

.v-enter-active,
.v-leave-active {
  transition: all 0.5s ease;
}

.myF-enter,
.myF-enter-to {
  opacity: 0;
  transform: translateY(100px);
}

.myF-enter-active,
.myF-leave-active {
  transition: all 0.5s ease;
}
</style>
